< previous page page_81 next page >

Page 81
Chapter 3
Advanced Color
Chapter 1 describes the fundamentals of color in Visual Basic. Methods like PSet and Line take a parameter that indicates the color they should use. You can control the colors of other drawing operations using a drawing object's ForeColor, BackColor, and FillColor properties.
While these techniques allow a program to select one of the computer's available colors, they do not determine which colors are available. This chapter covers advanced color topics. It explains how to determine which colors are available on a computer and how to take best advantage of them.
The chapter begins with a discussion of the different color modes available to modern computers. This section explains how you can make your system use different color models.
Color Models
Color is almost synonymous with memory. To display many colors, a computer needs a lot of memory. For example, suppose you need your computer to display only 16 different colors at one time. Then you can make a table listing the 16 colors. To specify a pixel's color, you can give its index in this table.
You can use the values 0 through 15 to indicate each pixel's index. Because you can specify the values 0 through 15 using only 4 bits, you can represent each pixel with only 4 bits. The number of bits used to represent each pixel is called the model's color depth or color resolution.
If your monitor displays 640 pixels horizontally and 480 pixels vertically, you need a total of 640 * 480 * 4 = 1,228,800 bits = 153,600 bytes or roughly 150KB of memory to determine the colors of every pixel.

 
< previous page page_81 next page >